<?php

	namespace application\controller;

		require_once ("application/model/JBAccount.php");
		require_once ("application/view/View.php");
		require_once ("login/controller/LoginController.php");

		class Application
		{
			private $view;

			private $loginController;
			private $loginView;

			public function __construct()
			{
				$this->loginView = new \login\view\LoginView();
				$loginView = $this->loginView;
				$this->loginController = new \login\controller\LoginController($this->loginView);
				$this->view = new \application\view\View($loginView);
			}


			public function doFrontPage($myMessage)
			{
				$this->loginController->doToggleLogin();

				if ($this->loginController->isLoggedIn())
				{
					$loggedInUserCredentials = $this->loginController->getLoggedInUser();
					return $this->view->getLoggedInPage($loggedInUserCredentials);
				}
				else
				{
					return $this->view->getLoggedOutPage($myMessage);
				}
			}

//JB
			public function doCreateAccountPage($myMessage, $myTempName)
			{
				$this->loginController->doToggleLogin();

				if ($this->loginController->isLoggedIn())
				{
					$loggedInUserCredentials = $this->loginController->getLoggedInUser();
					return $this->view->getLoggedInPage($loggedInUserCredentials);
				}

				return $this->view->getCreateAccountPage($myMessage, $myTempName);
			}




		}
